import request from '@/utils/request'
// import qs from 'qs'

// 动态路由

// OSPFv3获取路由
export function getOspfv3Route (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/getOspfv3Route',
    method: 'post',
    data
  })
}

// OSPFv3添加路由
export function addOspfv3 (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/addOspfv3',
    method: 'post',
    data
  })
}

// OSPFv3删除路由
export function delOspfv3 (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/delOspfv3',
    method: 'post',
    data
  })
}

// OSPFv3获取协议信息
export function getOspfv3Info (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/getOspfv3Info',
    method: 'post',
    data
  })
}

// OSPFv3编辑信息
export function editOspfv3Info (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/editOspfv3Info',
    method: 'post',
    data
  })
}

// OSPFv3添加区域配置
export function addOspfv3Regional (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/addOspfv3Regional',
    method: 'post',
    data
  })
}

// OSPFv3删除区域配置
export function delOspfv3Regional (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/delOspfv3Regional',
    method: 'post',
    data
  })
}

// OSPFv3添加接口配置
export function addOspfv3Interface (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/addOspfv3Interface',
    method: 'post',
    data
  })
}

// OSPFv3删除接口配置
export function delOspfv3Interface (params) {
  var data = fromData(params)
  return request({
    url: 'dynamic_route/delOspfv3Interface',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}

// function fromData (params) {
//   var data = qs.stringify(params)
//   return data
// }
